import { GlobalEvent } from "../base/GlobalEvent";
import { ConstData } from "../base/ConstData";

const {ccclass, property} = cc._decorator;

@ccclass
export default class LoadingScene extends cc.Component {

    @property(cc.Label)
    progressLabel:cc.Label = null;
    @property(cc.ProgressBar)
    progressBar:cc.ProgressBar = null;

    onLoad(){
        GlobalEvent.on(GlobalEvent.Event.loadingSceneProgress,function(Event){
            this.updateProgress(Event.completedCount, Event.totalCount);
        }.bind(this), this);
        this.progressBar.totalLength = this.progressBar.node.width +10;
    }

    updateProgress(completedCount, totalCount){
        this.progressLabel.string = completedCount + "/" + totalCount;
        this.progressBar.progress = completedCount / totalCount;
    }
}
